<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}


//$queryString = "SELECT id,name as label, name as value FROM sale_header WHERE name LIKE '%".strtoupper($_GET['term'])."%'";
$queryString = "
SELECT 
  sale_header.id, 
  sale_supplier.fullname as label,
  sale_supplier.fullname as value
FROM 
  public.sale_supplier, 
  public.sale_header
WHERE 
  sale_header.supplier_id = sale_supplier.id  AND sale_supplier.fullname LIKE '%" . strtoupper($_GET['term']) . "%'";


$query = pg_query($connect, $queryString);
if (!$query) {
    echo 'query : ';
    return false;
}
$arrRegistros = pg_fetch_all($query);
echo json_encode($arrRegistros);
pg_close($connect);
